<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@include file="/context/mytags.jsp"%>
<div class="portlet box green">
	<div class="portlet-title">
		<div class="caption">
			<i class="fa fa-gift"></i>物流和仓库多对多
		</div>
	</div>
	<div class="portlet-body form">
		<form id="logisticsHasWarehouseForm"
			class="form-horizontal form-bordered"
			action="/logisticsHasWarehouse/save" method="post">
			<div class="form-group">
				<label class="col-md-3 control-label">logisticsId:</label>
				<div class="col-md-4">
					<select name="logisticsId" class="form-control">
						<c:forEach items="${logisticses }" var="logistics" varStatus="vs">
							<option value="${logistics.id }">${logistics.name }</option>
						</c:forEach>
					</select>
				</div>
			</div>
			<div class="form-group">
				<label class="col-md-3 control-label">warehouseId:</label>
				<div class="col-md-4">
					<input type="text" name="warehouseId" class="form-control"
						value="${warehouseId}" maxlength="10" style="display: none" /> <input
						type="text" class="form-control" disabled="disabled"
						value="${warehouseName}" maxlength="10" />
				</div>
			</div>
			<div class="form-actions">
				<div class="col-md-9 col-md-offset-3">
					<button type="button" class="btn btn-primary"
						onclick="saveRelation(this);">
						<spring:message code="btn.save"></spring:message>
					</button>
					<button type="reset" class="btn btn-default" onclick="cancels()">
						<spring:message code="btn.return"></spring:message>
					</button>
				</div>
			</div>
		</form>
	</div>
</div>
<script type="text/javascript"
	src="<c:url value="/static/custom/datepicker-util.js"></c:url>"></script>
<script type="text/javascript">
	$(function() {
		$('#logisticsHasWarehouseForm').validate();
	});
	/** 保存物流与仓库之间的关系 */
	function saveRelation(obj) {
		if ($(obj).closest('form').valid()) {
			$.when($.ajax({
				type : 'post',
				url : webRoot + $(obj).closest('form').attr('action'),
				data : $(obj).closest('form').serialize(),
				dataType : 'json'
			})).done(function(data) {
				alert(messages[data.result]);
				$(".panel-content").html("");
				$(".panel-search").show();
				test123(data.warehouseId);
			})
		}
	}
</script>